<!DOCTYPE html>
<html>
<head>
    <title>五宝回收</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="stylesheet" href="${s.base}/mobile/css/weui.min.css">
    <link rel="stylesheet" href="${s.base}/mobile/css/jquery-weui.min.css">
    <link rel="stylesheet" href="${s.base}/mobile/css/base.css">
    <link rel="stylesheet" href="${s.base}/mobile/css/component.css?1232445">
    <style type="text/css">
		body,html{background: #e4e4e4;}
    </style>
</head>
<body>
<div class="xyg-comp-form">
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                兑换商品
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" id="area" value="${shopItem.title}" disabled />
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                兑换积分
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" id="phone" value="${shopItem.integral}积分" disabled />
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item">
            <div class="xyg-comp-form-item-upload">
                <div class="xyg-comp-form-item-upload-pic" id="uploaderFiles" data-objectId="">
                    <img src="${shopItem.image}"/>
                </div>
                <div class="clearBoth"></div>
            </div>
        </div>
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                收货人
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" id="memberName" placeholder="请输入收货人"  />
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                联系电话
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" id="memberPhone" placeholder="请输入联系电话"  />
            </div>
            <div class="clearBoth"></div>
        </div>
       <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                收货地址
            </div>
            <div class="xyg-comp-form-item-content"> 
             <input type="text" id="memberAddress" placeholder="请输入收货地址" />
            </div>
            <div class="clearBoth"></div>
       </div>
        <div style="line-height: 60px; height: 60px; color: #ff0000; padding-left: 30px;">我们将通过快递邮寄给您,请注意接收！</div>
        <input type="button" id="save" onclick="submit()" class="xyg-btn-one color-bs margin-top-1rem" value="提交"/>
  	</div>
</body>
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script src="${s.base}/mobile/js/jquery-2.1.4.js"></script>
<script src="${s.base}/mobile/js/jquery-weui.js"></script>
<script src="${s.base}/mobile/fonts/iconfont.js"></script>
<script src="${s.base}/mobile/js/component.js"></script>
<script src="${s.base}/mobile/js/base.js"></script>
<script src="${s.base}/mobile/js/ajaxfileupload.js"></script>

<script>
    var memberId = '${memberId}';
    var name = '${shopItem.title}';
    var itemId = '${shopItem.id}';
    var integral='${shopItem.integral}';
    var score = '${webMember.score}';
    var remainderNum = '${shopItem.remainderNum}';
    function submit() {
        var memberName = $("#memberName").val();
        var memberPhone = $("#memberPhone").val();
        var memberAddress = $("#memberAddress").val();
        if (parseInt(remainderNum) <= 0) {
            $.alert("商品数量不够，请联系管理员！");
            return false;
        }
        if (parseInt(score) <= parseInt(integral)) {
            $.alert("您的积分不够！");
            return false;
        }
        if (memberName == null || memberName == "") {
            $.alert("请输入收货人！");
            return false;
        }
        if (memberPhone == null || memberPhone == "") {
            $.alert("请输入联系方式！");
            return false;
        }
        if (memberAddress == null || memberAddress == "") {
            $.alert("请输入收货地址！");
            return false;
        }

        $.confirm("确定花费"+integral+"个积分，兑换【"+name+"】吗?","积分兑换",function () {
            $.showLoading("正在提交中");
            $.post("/phone/shoporder/orderSave", {'itemId':itemId,'memberId':memberId,'memberName':memberName,
                'memberPhone':memberPhone, 'memberAddress':memberAddress}, function (result) {
                if (0 == result.code) {
                    $.hideLoading();
                    $.alert("兑换成功，我们将会及时处理！",function () {
                        goShopOrderListPage(memberId);
                    });
                } else {
                    $.hideLoading();
                    $.alert(result.msg);
                }
            }, "json");
        });
    }
</script>
</html>
